package com.cy.pj.sys.service.impl;


import com.cy.pj.common.web.pojo.Input;
import com.cy.pj.common.web.pojo.JSONObject;
import com.cy.pj.sys.dao.LeaveDetailsDao;
import com.cy.pj.sys.pojo.LeaveDetail;
import com.cy.pj.sys.service.IApprovalDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class LeaveDetailService implements IApprovalDetailService {
    @Autowired
    LeaveDetailsDao leaveDetailsDao;

    @Override
    public void reporting(Input input) {
        LeaveDetail leaveDetail = input.getLeaveDetail();
        leaveDetail.toDetails(input.getApproval());
        leaveDetailsDao.insertLeaveDetail(leaveDetail);
    }

    @Override
    public JSONObject getDetail(Input input) {
        Long approvalId = input.getApproval().getApprovalId();
        return new JSONObject(leaveDetailsDao.selectLeaveDetail(approvalId));
    }

    @Override
    public void pass(Input input) {
        Long approvalId = input.getApproval().getApprovalId();
        leaveDetailsDao.updateLeaveDetail(approvalId, 1);
    }

    @Override
    public void reject(Input input) {
        Long approvalId = input.getApproval().getApprovalId();
        leaveDetailsDao.updateLeaveDetail(approvalId, 2);
    }
}
